'use strict';
const Controller = require('egg').Controller;

class BooksController extends Controller {
  async index() {
    const { ctx } = this;
    const query = ctx.request.query;
    const res = await ctx.service.books.getProjectById(query.title);
    ctx.body = res; // 返回值显示
  }

  async add() {
    const { ctx } = this;
    const res = await ctx.service.books.addBook();
    ctx.body = res; // 返回值显示
  }

  async query() {
    const { ctx } = this;
    const query = ctx.request.query;
    const res = await ctx.service.books.queryByTitle(query.title);
    ctx.body = res; // 返回值显示
  }
}
module.exports = BooksController;
